package wsi.gui.tool;

import java.io.File;

import org.rygh.core.util.UIo;
import org.rygh.gui.swing.USwing;
import org.rygh.gui.swing.common.window.SInfoWindow;
import org.rygh.semantic.jena.SDataAccess;
import org.rygh.semantic.model.ex.FactSet;

import wsi.function.DirManager;
import wsi.function.Function;

public class DBSaver {

	public DBSaver() {

	}

	public void save(Function function) {
		FactSet facts = SDataAccess.getInsertedFacts();

		if (facts.isEmpty()) {
			USwing.message("Database is empty.");
			return;
		}

		DirManager dir = new DirManager(function);

		UIo.saveFile(new File(dir.getDebugDir(), "injected_facts.txt"),
				facts.toJsonString());

		SInfoWindow.display(function.getName(), "Saving Database Completed.");
	}
}
